package model.backup.handlers;

import database.Database;
import java.sql.SQLException;
import model.backup.BackupCustomerAddress;

/**
 *  Denne klasse bruges til at hente al data i bs_customer_address og returnere det
 * @author junjie
 */
public abstract class BackupCustomerAddressHandler {
    /**
     * Henter alle rækker i bs_customer_address og returnerer et BackupCustomerAddress[] model
     * @return BackupCustomerAddress[]
     * @throws ClassNotFoundException
     * @throws SQLException 
     */
    public static BackupCustomerAddress[] getCustomerAddress() throws ClassNotFoundException, SQLException{
        BackupCustomerAddress[] customerAddressArray = null;
        
        Database db = new Database();
        
        String[][] result = db.getFromDB("bs_customer_address", "","","","fk_customer", "fk_address");
        customerAddressArray = new BackupCustomerAddress[result.length];
        
        db.closeDB();
        
        for(int i = 0; i< result.length;i++){
            customerAddressArray[i] = new BackupCustomerAddress(Integer.parseInt(result[i][0]),Integer.parseInt(result[i][1]));
                                                           
        }
        return customerAddressArray;
    }
}
